<template>
  <BasicModal v-bind="$attrs" @register="register" showFooter :title="getTitle" width="70%" :show-ok-btn="false"
    :showCancelBtn="false" @cancel="cancelFn">

    <div style="width: 100%; height: 300px">
      <!-- v-on="gridEvents" overflow: hidden -->
      <div>
        审批单据编号: <span>{{approveNo}}</span>
      </div>
      <div v-if="dataList.stateName">该单据 <span style="color: red;">{{ dataList.stateName }}</span> 请重新发起审批</div>
      <vxe-grid ref="tableRef" v-bind="gridOptions">
        <template #toolbar_buttons>

        </template>
        <template #footer_totalAllPrice>
          <span style="color: red;">{{ totalObj.totalAllPrice }}{{ totalObj.totalAllPrice ? '元' : '' }}</span>
        </template>
        <template #footer_orderCommissionPrice>
          <span style="color: red;">{{ totalObj.orderCommissionPrice }}{{ totalObj.totalAllPrice ? '元' : '' }}</span>
        </template>
        <template #footer_receiverUserPrice>
          <span style="color: red;">{{ totalObj.receiverUserPrice }}{{ totalObj.receiverUserPrice ? '元' : '' }}</span>
        </template>
        <template #footer_merchandiserUserPrice>
          <span style="color: red;">{{ totalObj.merchandiserUserPrice }}{{ totalObj.merchandiserUserPrice ? '元' : ''
            }}</span>
        </template>
        <template #footer_manageUserPrice>
          <span style="color: red;">{{ totalObj.manageUserPrice }}{{ totalObj.manageUserPrice ? '元' : '' }}</span>
        </template>
        <template #footer_xiangMuGroupPrice>
          <span style="color: red;">{{ totalObj.xiangMuGroupPrice }}{{ totalObj.xiangMuGroupPrice ? '元' : '' }}</span>
        </template>
        <template #footer_jiJingPrice>
          <span style="color: red;">{{ totalObj.jiJingPrice }}{{ totalObj.jiJingPrice ? '元' : '' }}</span>
        </template>
      </vxe-grid>

    </div>

  </BasicModal>
</template>
<script lang="ts" setup>
import { ref, computed, unref, h, toRaw, reactive } from 'vue';
import { BasicForm, useForm } from '@/components/Form';

import {
  BasicTableProps,
  VxeBasicTable,
  VxeGridInstance,
  VxeGridListeners,
  VxeTableDefines,
} from '@/components/VxeTable';
import {
  vxeTableColumns, confirmColumns
} from './role.data';
import {
  checkboxCountFn2
} from '../dknMoneyList/role.data';
import { BasicModal, useModalInner } from '@/components/Modal';
import { Form, FormItem, Input, InputNumber, DatePicker, Select, Switch } from 'ant-design-vue';

import { BasicTree, TreeItem } from '@/components/Tree';
import { moneyAffrimLogList } from '@/api/heng/ywManage';


import { useMessage } from "@/hooks/web/useMessage";
import util from '@/utils/util';

const emit = defineEmits(['success', 'register']);
const isUpdate = ref(true);
const treeData = ref<TreeItem[]>([]);
const { createMessage } = useMessage();
const mouldMainId = ref("");

const formData = ref({})
const totalObj = ref({});

const tableRef = ref<VxeGridInstance>();

const gridOptions = reactive<BasicTableProps>({
  // keepSource: true,
  border: true,
  showOverflow: true,
  size: 'mini',
  height: 'auto', // 'auto'
  columns: confirmColumns,
  filterConfig: {
    remote: true,
  },
  exportConfig: {},

  showFooter: true,
  footerData: [
    { orderNo: '合计' }
  ],
  toolbarConfig: {
    slots: {
      buttons: 'toolbar_buttons',
    },
    refresh: true,
  },

  pagerConfig: {
    enabled: false
  },

});


const dataList = ref({});
const approveNo=ref("");
const [register, { setModalProps, closeModal }] = useModalInner(async (data) => {
  //打开弹层后的回调
  // resetFields();
  setModalProps({ confirmLoading: false });
  dataList.value = data.record;
  approveNo.value =data.record.approveNo;
    moneyAffrimLogList({ approveNo: data.record.approveNo }).then(res => {
    if (res.code == 200) {
      tableRef.value?.reloadData(res.data);
      totalObj.value = checkboxCountFn2(res.data);
      gridOptions.footerData = [{ orderNo: "合计:" + res.data.length + "条" }];

    }
  })

});

const getTitle = computed(() => ('业务抽成明细'));


//async function handleSubmit()

const handleSubmit = () => {
  try {

    // const values = await validate();



  } catch (e) {
    console.log(e)
  } finally {
    setModalProps({ confirmLoading: false });

  }
}

function sunccFn(result) {
  if (result && result.code == 200) {
    createMessage.success(result.message);
  } else {
    createMessage.error(result.message);
  }
  closeModal()
  emit('success');
}

function cancelFn() {
  //  tableRef.value.clearValidate();
}



</script>
<style lang="less">
.item-row {
  margin: 0 auto;

  //padding-left: 5%;
  .ant-form-item-label {
    flex: 0 0 28.5%;
    max-width: 28.5%;
  }
}

.lqfp-8 {
  //padding-left: 9% !important;

}
</style>
